{% macro interface(interface, lindex) -%}
{
  "title": "{{interface.name}} : Members {{ interface.status | join(", ") }}",
  "aliasColors": {},
  "bars": false,
  "internal_comment":"graph_interface_load_lag.j2",
  "datasource": null,
  "fill": 1,
  "grid": {
    "threshold1": null,
    "threshold1Color": "rgba(216, 200, 27, 0.27)",
    "threshold2": null,
    "threshold2Color": "rgba(234, 112, 112, 0.22)"
  },
  "id": {{lindex + 200}},
  "legend": {
    "alignAsTable": true,
    "avg": true,
    "current": true,
    "max": true,
    "min": true,
    "show": true,
    "sortDesc": true,
    "total": false,
    "values": true
  },
  "lines": true,
  "linewidth": 2,
  "links": [],
  "minSpan": 6,
  "nullPointMode": "connected",
  "percentage": false,
  "pointradius": 5,
  "points": false,
  "renderer": "flot",
  "repeat": "",
  "seriesOverrides": [
    {
      "alias": "/Input.+/",
      "transform": "negative-Y"
    }
  ],
  "span": 12,
  "stack": false,
  "steppedLine": false,
  "targets": [
  {% set comma = joiner(",") -%}
  {%for port in interface.ports %}
  {{ comma() }}
      {
      "intervalFactor": 1,
      "query": "SELECT $timeSeries as t, avg(load_in) as `Input {{ port }}`,  avg(load_out) as `Output {{ port }}`, avg(status_oper) as `Oper status`, avg(status_admin) as `Admin status` FROM $table WHERE managed_object = $bi_id and path[4]=toString('{{port}}') and $timeFilter GROUP BY t ORDER BY t",
      "refId": "A",
      "resultFormat": "time_series",
      "database": "noc",
      "tableLoading": false,
      "table": "interface",
      "dateLoading": false,
      "datetimeLoading": false,
      "dateColDataType": "date",
      "dateTimeColDataType": "ts"
    }
  {%endfor%}
  ],
  "timeFrom": null,
  "timeShift": null,
  "tooltip": {
    "msResolution": false,
    "shared": true,
    "sort": 0,
    "value_type": "cumulative"
  },
  "type": "graph",
  "xaxis": {
    "show": true
  },
  "y-axis": true,
  "yaxes": [
    {
      "format": "bps",
      "label": "bit/s",
      "logBase": 1,
      "max": null,
      "min": null,
      "show": true
    },
    {
      "format": "short",
      "label": null,
      "logBase": 1,
      "max": null,
      "min": null,
      "show": true
    }
  ]
}
{%- endmacro %}
